﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
	String basePath = "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="/">
    <meta charset="utf-8"/>
    <script type="text/javascript" src="static/js/jquery-1.7.2.js"></script>
    <link type="text/css" rel="stylesheet" href="plugins/zTree/3.5/zTreeStyle.css"/>
    <script type="text/javascript" src="plugins/zTree/3.5/jquery.ztree.core-3.5.js"></script>
<body>

<table style="width:100%;" border="0">
    <tr>
        <td style="width:15%;" valign="top" bgcolor="#F9F9F9">
            <div style="width:15%;">
                <ul id="leftTree" class="ztree"></ul>
            </div>
        </td>
        <td style="width:85%;" valign="top">
            <iframe name="treeFrame" id="treeFrame" frameborder="0" src="<%=basePath%>goods/list.do"
                    style="margin:0 auto;width:100%;height:100%;"></iframe>
        </td>
    </tr>
</table>

<script type="text/javascript">
    $(top.hangge());
    var setting = {
        data: {
            simpleData: {
                enable: true,
            }
        },
        async: {
            enable: true,
            url: "goods/asynTree.do",
            autoParam: ["id", "name", "level"],
            /*    otherParam:{"otherParam":"zTreeAsyncTest"}, */
            dataFilter: filter
        },
        showLine: true
    };

    function filter(treeId, parentNode, childNodes) {
        if (!childNodes) return null;
        for (var i = 0, l = childNodes.length; i < l; i++) {
            childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
        }
        return childNodes;
    }

    var zNodes = [
        {id: 0, pId: 0, name: "商品分类", isParent: true, open: true}
    ];

    $(document).ready(function () {
        $.ajax({
            type: 'get',
            data: {id: 0},
            url: 'goods/asynTree.do',
            dataType: "json", //可以是text，如果用text，返回的结果为字符串；如果需要json格式的，可是设置为json
            success: function (data) {
                $.fn.zTree.init($("#leftTree"), setting, data);

            },
            error: function (msg) {

                alert(" 数据加载失败！" + msg);
            }
        });

    });

    function treeFrameT() {
        var hmainT = document.getElementById("treeFrame");
        var bheightT = document.documentElement.clientHeight;
        hmainT.style.width = '100%';
        hmainT.style.height = (bheightT - 26) + 'px';
    }

    treeFrameT();
    window.onresize = function () {
        treeFrameT();
    };
</SCRIPT>
</body>
</html>

